package com.example.design_pattern.observer;

/**
 * Created by SQ_BXZ on 2019-02-16.
 *  布告板 - 当前状况
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    public void display() {
        System.out.println("CurrentConditionsDisplay Current conditions: " + temperature
                + "F degrees and " + humidity + "% humidity");
    }

    public void update(float temperature, float humidity, float pressure) {
        this.temperature =temperature;
        this.humidity = humidity;
        display();
    }
}
